package com.company;

public class Test14闰年计算 {
    public static void main(String[] args) {
        System.out.println(calYear(2016,4,31));
        System.out.println(calYear(2011,5,2));
    }

    /**
     * 计算天数
     * @param year
     * @param month
     * @param day
     * @return
     */
    public  static int calYear(int year,int month,int day){
        int str[]={31,28,31,30,31,30,31,31,30,31,30,31};
        int totalDay=0;
            for(int i=1;i<month;i++){
                totalDay=totalDay+str[i];
            }
        if(year%400==0||(year%4==0&&year%100!=0)){
            totalDay=totalDay+1;
        }
        return totalDay+day;
    }
}
